"use strict";
cc._RF.push(module, '14cc97JUYJKyLHeB8Y2fKwp', 'SceneNavigator');
// eazax-ccc/core/SceneNavigator.ts

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * 场景导航类
 * @see SceneNavigator.ts https://gitee.com/ifaswind/eazax-ccc/blob/master/core/SceneNavigator.ts
 * @version 20210318
 */
var SceneNavigator = /** @class */ (function () {
    function SceneNavigator() {
    }
    Object.defineProperty(SceneNavigator, "home", {
        /** 首页场景名称 */
        get: function () { return this._home; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SceneNavigator, "history", {
        /** 历史记录（栈） */
        get: function () { return this._history; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SceneNavigator, "curScene", {
        /** 当前场景名称 */
        get: function () { return this._curScene; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SceneNavigator, "param", {
        /** 上一个场景留下的参数（ onLaunched 之后可用） */
        get: function () { return this._param; },
        enumerable: false,
        configurable: true
    });
    /**
     * 设置首页
     * @param name 场景名
     */
    SceneNavigator.setHome = function (name) {
        this._home = name;
        this._history = [name];
        this._curScene = name;
    };
    /**
     * 返回首页
     * @param param 数据
     * @param coverHistory 覆盖历史记录
     * @param onLaunched 场景加载完成回调
     */
    SceneNavigator.goHome = function (param, coverHistory, onLaunched) {
        var _this = this;
        this._param = null;
        var name = this._home;
        if (this._curScene === name) {
            return;
        }
        cc.director.loadScene(name, function () {
            if (coverHistory) {
                _this._history.length = 0;
            }
            _this._history.push(name);
            _this._curScene = name;
            _this._param = param || null;
            onLaunched && onLaunched();
        });
    };
    /**
     * 前往场景
     * @param name 场景名
     * @param param 数据
     * @param onLaunched 场景加载完成回调
     */
    SceneNavigator.go = function (name, param, onLaunched) {
        var _this = this;
        this._param = null;
        cc.director.loadScene(name, function () {
            _this._history.push(name);
            _this._curScene = name;
            _this._param = param || null;
            onLaunched && onLaunched();
        });
    };
    /**
     * 返回上一个场景
     * @param param 数据
     * @param onLaunched 场景加载完成回调
     */
    SceneNavigator.back = function (param, onLaunched) {
        var _this = this;
        if (this._history.length < 1) {
            return;
        }
        this._param = null;
        var history = this._history, name = history[history.length - 2];
        cc.director.loadScene(name, function () {
            history.pop();
            _this._curScene = name;
            _this._param = param || null;
            onLaunched && onLaunched();
        });
    };
    SceneNavigator._home = null;
    SceneNavigator._history = [];
    SceneNavigator._curScene = null;
    SceneNavigator._param = null;
    return SceneNavigator;
}());
exports.default = SceneNavigator;

cc._RF.pop();